<!DOCTYPE html>
<html lang="en">
<head>
<!--    点击按钮获取笑话渲染到页面-->
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../node_modules/axios/dist/axios.js"></script>
    <script src="../node_modules/vue/dist/vue.js"></script>
</head>
<body>
<!--axios回调函数中的this已经改变，无法访问到data中的数据-->
<div id="app">
    <button @click="small">获取笑话</button>
    <h2>{{content}}</h2>
</div>
<script>
    var app=new Vue({
        el:"#app",
        data: {
            content:"132"
        },
        methods:{
            small:function () {
                axios.get("https://autumnfish.cn/api/joke").then(
                    function (response) {
                        app.content=response.data
                        console.log(response)
                    },function (err) {
                        console.log(err)
                    }
                )
            }
        }
    })
</script>
</body>
</html>